import { BaseEntity } from '@cool-midway/core';
import { Column, Entity, Index } from 'typeorm';

/**
 * Layout style interface
 */
interface LayoutStyle {
  container?: string;
  title?: string;
}

/**
 * Layout configuration entity
 */
@Entity('app_layout')
export class LayoutEntity extends BaseEntity {
  @Index()
  @Column({ comment: 'Layout component ID', length: 50 })
  componentId: string;

  @Index()
  @Column({ comment: 'Layout component type', length: 50 })
  type: string;

  @Column({ comment: 'Title', length: 100, nullable: true })
  title: string;

  @Column({ comment: 'Show title', default: false })
  showTitle: boolean;

  @Column({ comment: 'Visibility status', default: true })
  isVisible: boolean;

  @Column({ comment: 'Display order', default: 0 })
  order: number;

  @Column({ comment: 'Category ID', nullable: true })
  categoryId: number;

  @Column({ comment: 'Grid columns', nullable: true })
  gridCols: number;

  @Column({ comment: 'Style configuration', type: 'json', nullable: true })
  style: LayoutStyle;

  @Column({ comment: 'Additional configuration', type: 'json', nullable: true })
  config: Record<string, any>;
}
